package com.zhangliang;

import com.zhangliang.bean.ConsumerConponent;
import com.zhangliang.filter.TPMonitorFilter;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

public class AnnotationDubboConsumerMain {

    public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();

        // 获取消费者组件
        ConsumerConponent service = context.getBean(ConsumerConponent.class);

        while(true) {
            Thread.sleep(10);

            new Thread(new Runnable() {
                @Override
                public void run() {
                    String res1 = service.methodA();
//                System.out.println(res1);
                    String res2 = service.methodB();
//                System.out.println(res2);
                    String res3 = service.methodC();
//                System.out.println(res3);
                }
            }).start();

        }
    }


    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    @ComponentScan("com.zhangliang.bean")
    @EnableDubbo
    static class ConsumerConfiguration {

    }
}
